import java.util.Arrays;

public class MyStack implements IStack{
    private int[] elem;
    private  int useszie;
    private static final int DEF=10;
    private MyStack(){
        elem=new int[DEF];
    }
    @Override
    public void push(int x) {
        if (full()){
            elem= Arrays.copyOf(elem,2*elem.length);

        }
        elem[useszie]=x;
        useszie++;

    }

    @Override
    public int pop() {
        if (empty()){
            return -1;
    }
        int old=elem[useszie-1];
        useszie--;
        return old;

    }

    @Override
    public int peek() {
        if (empty()){
            return -1;
        }
        return elem[useszie-1];

    }

    @Override
    public int size() {

        return elem.length;
    }

    @Override
    public boolean empty() {
        if(useszie==0){
            return true;
        }
        return false;
    }

    @Override
    public boolean full() {
        if(useszie==elem.length){
            return true;
        }
        return false;
    }
}




